package com.example.tool.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.tool.entity.Dict;
import com.example.tool.entity.User;
import com.example.tool.mapper.DictMapper;
import com.example.tool.mapper.UserMapper;
import com.example.tool.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

@Service
@Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class)
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    @Autowired
    private UserMapper userMapper;
    @Override
    public List<User> list() {
        return userMapper.selectList(Wrappers.emptyWrapper());
    }

    @Override
    public User  findByUsername(String username) {
        return userMapper.selectOne(Wrappers.lambdaQuery(User.class).eq(User::getUsername, username));
    }

}
